#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i < n; i++)
		if (i * i % n * 2 < n)
			ans++;
	cout << ans;
	return 0;
}
